/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chat;
import langen.LanguageGenerator;
import langen.TemplateLanguageGenerator;



/**
 * A class representing a digital persona known as a chat bot.
 * The chat bot can start conversations and reply to remarks.
 * <p> Used in IJP assignments 1 and 2.</p>
 * <p><b> this class implements the basic functions of a chatbot, such as start a conversation, reply a sentence. If you want to use the chatbot,
 * you should set its language template. In this assignment, the language template is supplied by TemplateLanguageGenerator</b>
 * @author Judy Robertson, Nigel Goddard
 */
public class ChatBot {

    /**
     * The name of the chatbot
     */

    private String name;

    /**
     * description of chatbot
     */
    private String description;

    /**
     *
     */
private LanguageGenerator lan;
private TemplateLanguageGenerator def=new TemplateLanguageGenerator();
    /**
     * Create a ChatBot, initialise the language generator.
     * initialise the name and description
     *you should use the method set() if you want to use LanguageGenerator
     */

    public ChatBot(String name, String des) {
      this.name=name;
      this.description=des;
      this.setLanguageGenerator(def);

    }
    /**set the LanguageGenerator
     * the class discussion will set it to every chatbot so as to make the chatbot talkable
     */
    public void setLanguageGenerator(LanguageGenerator wh)
    {
        this.lan=wh;
    }
    /**
     * Initiate a conversation about any topic. Generate a starting sentence
     *
     * @return A sentence with which to start a conversation
     */

    public String startConversation() {
        String s="Ok, let's have a chat, what would you like to talk about?";
        System.out.println(s);//start a conversation with a static sentence

        return (this.lan.generateSentence());


    }

    /**
     * Generate a response to the specified remark
     *
     * @param remark The comment which must be responded to
     *
     * @return A sentence which represents a reply to the specified remark
     */
    public String reply(String remark) {
        String s=this.lan.generateReply(remark);//call the generatereply provided by interface to generate a reply which depends on remark
        System.out.println(s);//print the reply sentence
        return s;


    }



    /**
     * Gets the textual description of what the chat bot looks like and
     * its personality
     *
     * @return A textual description of the chat bot
     */
    public String getDescription() {
        return this.description;

    }

    /**
     * Gets the name of the chat bot
     *
     * @return The name of this chat bot
     */
    public String getName() {
        return this.name;

    }

    /**
     * Sets up the textual description of the chat bot's appearance and personality
     *
     * @param string The textual description of the bot
     */
    public void setDescription(String string) {
        this.description=string;

    }

    /**
     * Sets up the name of this digital persona
     *
     * @param string The name of the bot
     */
    public void setName(String string) {
        this.name=string;

    }

    static public void main(String[] argv) {
    	// create the game
    	ChatBot a=new ChatBot("big guy","i am a test chatbot");
    	// invoke a method to play the game until the end
        a.reply("guess who am i?");

    	// clean up after the game ends
    }


}

